package model

import (
	"gorm.io/gorm"
	"share-chat/global"
	"time"
)

type Like struct {
	Id        int32          `gorm:"column:id;type:int;comment:点赞ID;primaryKey;not null;" form:"id" json:"id"`                                // 点赞ID
	UserId    int32          `gorm:"column:user_id;type:int;comment:用户ID;not null;" form:"user_id" json:"user_id"`                            // 用户ID
	ShareId   int32          `gorm:"column:share_id;type:int;comment:分享ID;not null;" form:"share_id" json:"share_id"`                         // 分享ID
	Status    int8           `gorm:"column:status;type:tinyint(1);comment:状态 0:默认 1:点赞 2:取消点赞;not null;" form:"status" json:"status"` // 状态 0:默认 1:点赞 2:取消点赞
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);comment:创建时间;not null;" form:"created_at" json:"created_at"`         // 创建时间
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" form:"updated_at" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" form:"deleted_at" json:"deleted_at"`
}

func (l *Like) TableName() string {
	return "share"
}

func (l *Like) AddLike() error {
	return global.DB.Create(&l).Error
}
